<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
//-----------------------------------------------------------------------------
//  Copyright (C) 2005-2007 Thomas S. Ullrich 
//
//  This file is part of the Solitaire Mahjong project.
//
//  This file may be used under the terms of the GNU General Public License.
//  This project is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License.
//  
//  Author: Thomas S. Ullrich
//  Last update: June 4, 2007
//-----------------------------------------------------------------------------
 -->

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>hxBrowser - Tiles and Layouts</title>
	</head>

	<body bgcolor="#ffffff">
		<table width="650" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td>
					<h1><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Tiles and Layouts</font>
						<hr noshade>
					</h1>
				</td>
			</tr>
			<tr>
				<td>
					<h2><a id="Anchor-Mahjon-12676" name="Anchor-Mahjon-12676"></a><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Mahjong Tiles</font></h2>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">A Mahjong set contains a total of 144 tiles. Most of these form four series each of three suits: (Bamboo) Sticks, Wheels, and Numbers. </font></p>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Stick Suit</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">In earlier centuries, these pieces were depicted as spears. In modern games, they are bamboo sticks (<img src="swo3dz5.png"> <i>suozi</i>, or commonly called <i>t&igrave;ao</i>, meaning &quot;stick&quot;). Each set has four of each of the following pieces, numbered 1 through 9: </font></p>
					<center>
						<img src="bamboo.png"></center>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Note that the 1 of sticks is generally rendered as the image of a bird--usually a sparrow or peacock. </font></p>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Wheel Suit</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Anciently, these were depicted as coins or shields. Now they are called wheels or balls (<img src="tung3dz5.png"> <i>tongzi</i>). Again, each set has four of each of these pieces, numbered 1 through 9: </font></p>
					<center>
						<img src="wheels.png"></center>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Number Suit</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Finally, there is a suit consisting of the Chinese characters for the numerals 1 through 9 (<img src="wan4dz5.png"> <i>w&agrave;nzi</i>). The character on top of the tile face is the numeral; the character below that is the Chinese symbol <em>w&agrave;n</em> (<img src="wan4.png"> <i>w&agrave;n</i>), meaning 10,000. This suit is therefore also called the <em>w&agrave;n</em> suit. Each set contains four of each of these tiles: </font></p>
					<center>
						<img src="characters.png"></center>
					<div align="left">
						<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">For easier recognition this (western) version also depicts arabic numbers on the top right of each tile. </font></p>
					</div>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Wind Tiles</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Each game contains a set of tiles inscribed with the Chinese characters for the four compass directions, representing the four winds: </font></p>
					<center>
						<img src="winds.png"><br>
						<font size="-1" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">North, south, west, and east wind tiles.</font></center>
					<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">The four winds are: </font>
					<ul>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">East (<img src="dong.png"> <i>dong</i>) </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">South (<img src="nan3.png"> <i>nan</i>) </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">West (<img src="syi1.png"> <i>xi</i>) </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">North (<img src="bei3.png"> <i>bei</i>) </font>
					</ul>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">There are four of each of these tiles in the game. </font></p>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Dragon Tiles</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">These pieces are called &quot;dragons&quot; in the West: the red dragon (<img src="hung2jung1.png"> <i>h&oacute;ngzhong</i>), symbolizing the &quot;middle&quot; or &quot;animal&quot; order, including humans (<i>zhong</i> is the Chinese character meaning &quot;center&quot;), the green dragon (<img src="ching1fa1.png"> <i>qingfa</i>), symbolizing the &quot;lower&quot; or &quot;plant&quot; order of life, and the white dragon (<img src="bai2pi2.png"> <i>b&aacute;ip&iacute;</i>), symbolizing the &quot;higher&quot; order of spiritual beings). </font></p>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">There are four of each dragon in a Mahjong set. </font></p>
					<center>
						<img src="dragons.png"><br>
						<font size="-1" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">White, red, and green dragon tiles</font></center>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Note that the &quot;white dragon&quot; tile is simply a plain white tile with or without a rectangular border drawn on it. In some versions there is a B for <i>bai</i> in Mandarin or P for <i>pa</i> in Cantonese which means white in both case. In some western versions of the &quot;green dragon&quot; there is a F for <i>fa</i> in Mandarin and a C for <i>chong</i> in Cantonese, the equivalent of <i>zhong</i> in Mandarin for the &quot;red dragon&quot;. The tile set used in this game doesn't have the characters depicted. I think that their appearance is unique enough to make them easily distinguishable from each other.</font></p>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Flower Tiles</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">There are eight &quot;flower tiles&quot; (<img src="hwa1pai2.png"> <i>huap&aacute;i</i>) in each Mahjong set. While they are all collectively called &quot;flower tiles&quot; in these rules, four of them represent different flower blossoms, while the other four represent the four seasons. </font></p>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Each of these tiles represents a different flower, and is associated with a specific wind, which has relevance only for scoring purposes. There is only one pair of each flower tile in a Mahjong set. </font></p>
					<center>
						<img src="flowers.png"></center>
					<ol>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Orchid (<img src="lan2.png"> <i>l&aacute;n</i>) -- South </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Chrysanthemum (<img src="jyu2.png"> <i>j&uuml;'</i>) -- West </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Bamboo (<img src="ju2.png"> <i>zh&uacute;</i>) -- North </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Plum (<img src="mei2.png"> <i>m&eacute;i</i>) -- East </font>
					</ol>
					<h3><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Season Tiles</font></h3>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">These are just like the flower tiles; they do not enter play except to enhance the score of a players hand. There is only one pair of each season tile. </font></p>
					<center>
						<img src="seasons.png"></center>
					<ol>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Spring (<img src="chwen1.png"> <i>chwen</i>) -- East </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Summer (<img src="sya4.png"> <i>xi&agrave;</i>) -- South </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Autumn (<img src="chyou1.png"> <i>qiu</i>) -- West </font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Winter (<img src="dong1.png"> <i>dong</i>) -- North </font>
					</ol>
					<h2><a id="Anchor-Mahjon-64307" name="Anchor-Mahjon-64307"></a><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Mahjong Layouts</font></h2>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">The standard layout (shown below) has been called '<i>The Turtle</i>', '<i>The Pyramid</i>' and '<i>The Dragon</i>' layout.&nbsp;</font></p>
					<div align="center">
						<p><img src="turtle.png" alt="" height="341" width="496" border="0"><br>
							<font size="-1" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Standard Layout: The Turtle</font></p>
					</div>
					<p><font size="3" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">The original layout was called '<i>The Turtle</i>' by the creator Brodie Lockard in the 1981 Mah-Jong. The original configuration was intended to look like a turtle.</font></p>
					<p><font size="3" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">In 1986 the Shanghai game described the standard layout as &quot;arranged in a dragon- shaped pyramid&quot;. It was Activision's marketing department that came up with this 'dragon description'.</font></p>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">According to <i>Tom Sloper</i> there are four &quot;schools&quot; of how to create a layout (tile arrangement) or &quot;board&quot;:</font></p>
					<ol>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">&quot;<i>Canned, and winnable</i>&quot;. Japanese programmers tend to create &quot;canned&quot; tile arrangements - they are carefully planned and arranged to have just the right amount of traps, yet be winnable. There is no mathematical program algorithm at all - the tile arrangements are all carefully planned by a game designer. You get a very limited number of arrangements, but a challenging game. The drawback is that some players can memorize the pattern for removing the pairs.</font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">&quot;<i>Random</i>&quot; - Many programmers (as the author of this game) tend to create purely &quot;random&quot; tile arrangement - with no guarantee as to winnability or challenge. You get a huge number of possible arrangements. The probability that a random setup is winnable is actually quite large (83%). More information on that can be found <a href="#Anchor-Probabilit-23564">below</a>.</font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">&quot;<i>Random, but winnable</i>&quot; - Every game is winnable (at least one path to victory and possibly several to failure). The program uses an algorithm to arrange the tiles a pair at a time, from the bottom and up. You still get a lot of possible arrangements.</font>
						<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">The game uses a &quot;<i>seed</i>&quot; number to generate some arrangements, not all of which are solvable.&nbsp;</font>
					</ol>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">This <a href="version.html">version</a> offers to-date only one layout, '<i>The Turtle</i>' of course, although others might follow. The layout is created randomly, that is at times the game is not solvable. Remember that not winning doesn't mean it's not winnable. In fact around 83% of all randomly selected cases there does exist a solition (see below). You will be amazed how often you will succeed by <a href="intro.html#Anchor-Repla-64301">replaying</a> a given layout a couple of times.</font></p>
					<p></p>
					<h2><a id="Anchor-Probabilit-23564" name="Anchor-Probabilit-23564"></a><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Probability, Statistics, and the Tools Menu</font></h2>
					<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">As mentioned above this version of Solitaire Mahjong uses randomly generated tile arrangements meaning that the position of each tile in the layout is determined by a random generator. That raises the question how often a winnable arrangement is generated, that is an arrangement where all tiles can be removed. <em>Solitaire Mahjong</em> provides some tools related to this. All can be found in the Tools menu.</font></p>
					<div align="center">
						<p></p>
						<table border="0" cellspacing="2" cellpadding="0">
							<tr>
								<td>
									<p><img src="screenshot-tools.png" alt="" border="0"></p>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font size="-1" face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">The Tools menu.</font></div>
								</td>
							</tr>
						</table>
					</div>
					<ol>
						<div align="left">
							<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular"><b>Finish Game:</b> The computer takes over the role of the user and finishes the game. The next move is randomly selected from all possible moves. The computer will not find the best way, it will pick <em>one</em> possible way. This is equivalent to a human player who simply picks the first best move without using any <a href="rules.html#Anchor-Th-30724">strategy</a>. </font>
							<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular"><b>Find Solution:</b> This launches an algorithm that tries to find a solution for the current game. How does it works? I picked a rather time consuming but simple method. I let the computer repeatedly play against itself pretty similar as above but many, many times on the same game. The probability that the computer wins a solvable game in the first attempt is small. Same is of course true for a human player not using any <a href="rules.html#Anchor-Th-30724">strategy</a>. But this is were a modern fast CPU kicks in. We can replay the same game over and over again, say 100 or 1000 times. This way all possible combinations of moves are randomly sampled. The more often this is done for an arrangement the more precise the final answer: solvable or not. A more general question is: what is the minimum number of tiles that cannot be removed any more. When you select this command, a dialog box asks you to enter the amount of iterations. Start with a number around 50 first. To make sure you really sample all combinations you will need a substantially larger number but in many cases 100 will do. If the layout is solvable you have the option to save the solution in a text file. The file content is pretty self explanatory. Note that the row, column, and layer numbering starts with a 0, e.g., the first layer is layer 0. If the maximum number of iterations is reached and no solution was found the least number of tiles achieved is printed in the status bar. Note that this feature is <strong>very</strong> slow on the Mac. </font>
							<li><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular"><b>Analyze Layout:</b> In order to collect statistics on a given <a href="#Anchor-Mahjon-64307">layout</a> (in this case the &quot;turtle&quot; layout) one can repeat this procedure for many many games. For 10,000 games with 1000 iteration each, one obtains already a sufficiently precise answer:</font>
						</div>
					</ol>
					<div align="center">
						<p><img src="turtle-analysis-graph.png" alt="" height="324" width="500" border="0"></p>
					</div>
					<div align="left">
						<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Or in plain numbers:</font></p>
					</div>
					<div align="center">
						<table border="1" cellspacing="2" cellpadding="5" align="center">
							<tr>
								<td><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Tiles Left</font></td>
								<td><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Probability (%)</font></td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">0</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">82.93</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">2</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">4.10</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">4</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">1.83</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">6</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">1.53</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">8</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">1.11</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">10</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">1.09</font></div>
								</td>
							</tr>
							<tr>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">12</font></div>
								</td>
								<td>
									<div align="center">
										<font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">0.89</font></div>
								</td>
							</tr>
						</table>
					</div>
					<div align="left">
						<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">This means that in 82.93% of all cases you get a tile arrangement that can be solved, in 4.1% you cannot do better than end up with 2 tiles on the boards etc. Another interesting number is the average number of tries, <i>T</i>, the algorithm (or any human playing without strategy) will need on average to win the game. It turns out to be a rather high number: <tt>&lt;</tt><i>T</i><tt>&gt;</tt> =89.2. This way one can analyze any tile layout and compare it to the &quot;turtle&quot;. The higher <tt>&lt;</tt><i>T</i><tt>&gt; </tt>the more difficult it is to solve. </font><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">Be warned this command can take hours to finish. This feauture is only useful when designing new layouts.</font></p>
						<p><font face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular"> </font></p>
					</div>
				</td>
			</tr>
			<tr>
				<td></td>
			</tr>
		</table>
	</body>

</html>